/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙，邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_framework/zhiqim_guestbook.htm
 *
 * Zhiqim Guestbook is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package org.zhiqim.example.gbook;

import org.zhiqim.example.gbook.dbo.Admin;
import org.zhiqim.httpd.HttpRequest;
import org.zhiqim.httpd.context.ZmlBootstrap;
import org.zhiqim.httpd.context.core.Context;
import org.zhiqim.orm.ORM;

/**
 * 系统启动引导类，用于检查管理员账号是否建立，如果没有则执行初始化脚本
 *
 * @version v1.0.0 @author zouzhigang 2017-2-28 新建与整理
 */
public class Bootstrap extends ZmlBootstrap
{
    /** 
     * 在配置加载之后,初始化系统接口
     * 
     * @throws Exception
     */
    public void init(HttpRequest request, Context context) throws Exception
    {
        if (ORM.table().count(Admin.class) > 0)
            return;
        
        Admin admin = new Admin();
        admin.setAdminName("zhiqim");
        admin.setAdminPass("zhiqim@2015");
        ORM.table().insert(admin);
    }
}
